<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<title>新建项目</title>
	<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css" />
	<link href="../css/select2.css" rel="stylesheet"/>
</head>
<body class="body">
	
	<div class="navbar navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
				<a class="brand" href="#">凯盛项目管理系统</a>
			</div>
		</div>
	</div>
	
	
	<div class="container">
	  <div class="row">
		<div class="span9">
			<form class="form-horizontal" action="new_project.jspx" method="post" enctype="application/x-www-form-urlencoded">
        <fieldset>
          <legend>开始一个新项目</legend>
          <div class="control-group">
            <label class="control-label" for="input01">项目名称</label>
            <div class="controls">
              <input type="text" autocomplete="off" name="project" class="span5" id="projectname" x-webkit-speech="undefined"><span id="erro1" style="background-color:#eee;padding:5px 5px 5px;display:none">项目名称不能为空</span>
              <p class="help-block">In addition to freeform text, any HTML5 text-based input appears like so.</p>
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" for="input01">项目描述</label>
            <div class="controls">
              <textarea class="span5" name="projectDesc" rows="4"></textarea><span id="erro2" style="background-color:#eee;padding:5px 5px 5px;display:none">项目描述不能为空</span>
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" for="multiSelect">负责人</label>
            <div class="controls">
              <select id="e2" name="employee" style="width:300px">
                <option></option>
                <c:forEach var="str" items="${requestScope.AllEmployee}">
                	<option>${str.name}</option>
                </c:forEach>
              </select>
              <span id="erro3" style="background-color:#eee;padding:5px 5px 5px;display:none">项目负责人不能为空</span>
            </div>
          </div>
         <div class="control-group">
            <label class="control-label" for="input01">项目成员</label>
            <div class="controls">
            <select id="e2_2" multiple="multiple" style="width:300px" class="populate placeholder select2-offscreen" tabindex="-1">
            	<option></option>
                <c:forEach var="str" items="${requestScope.AllEmployee}">
                	<option>${str.name}</option>
                </c:forEach>
            </select>
            <input type="hidden" id="hi" name="member"/>
		</div>
          </div>
          <div class="form-actions">
            <button type="button" id="btn" class="btn btn-primary">保存</button>
            <button class="btn" onclick="history.back()">返回</button>
          </div>
        </fieldset>
      </form>    
		</div>
		<div class="span3">
			
		</div>
	  </div>
	</div>
	<script type="text/javascript" src="../js/jquery.js"></script>
    <script src="../js/select2.js"></script>
	<script type="text/javascript">
		$(function(){
			$("#e2").select2({
				placeholder: "Select a Manager",
				allowClear: true
			});
			$("#e2_2").select2({
				placeholder: "Select Members"
			});
			$("#projectname").focus(function(){
				$("#erro1").hide();
			});
			$("textarea").focus(function(){
				$("#erro2").hide();
			});
			$("#e2").focus(function(){
				$("#erro3").hide();
			});
			$("#btn").click(function(){
				if(!$("#projectname").val()){
					$("#erro1").show();
					return;
				}else if(!$("textarea").val()){
					$("#erro2").show(); 
					return;
				}else if(!$("#e2").val()){
					$("#erro3").show();
					return;
				}
				$("#hi").val($("#e2_2").val());
				$(".form-horizontal").submit();
			});
		});
	</script>
</body>
</html>
